import java.io.IOException;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;

import entities.User;




public class EntityManagerTest {

	public static void main(String[] args) throws IOException {
	  
		EntityManagerFactory emf = javax.persistence.Persistence.createEntityManagerFactory("PU");	
		
		EntityManager em = emf.createEntityManager();
		
		User user = em.find(User.class, 1L);
		user.setCodigo(user.getCodigo() + 1);
		
		em.getTransaction().begin();
		em.merge(user);
		em.getTransaction().commit();
		
		emf.close();
		
		
  }
	
}
